package cn.itlaobing.eshop.service;

import cn.itlaobing.eshop.dao.UserDao;
import cn.itlaobing.eshop.entity.Users;
import cn.itlaobing.eshop.exception.BusinessExceeption;

import java.sql.SQLException;

/**
 * Created by Administrator on 2017/11/17.
 */
public class UserService {
    private UserDao ud=new UserDao();

    /**
     * 登录
     * @param userAccount
     * @param userPassword
     * @return
     * @throws BusinessExceeption
     */
    public Users login(String userAccount,String userPassword)throws BusinessExceeption{

        Users users=null;

        try {
            users=ud.login(userAccount,userPassword);
        } catch (SQLException e) {
            e.printStackTrace();
            throw new BusinessExceeption(e.getMessage());
        }
        return users;

    }

    /**
     * 注册
     * @param users
     * @return
     * @throws BusinessExceeption
     */
    public int register(Users users)throws BusinessExceeption{
        int r=0;
        try {
            r=ud.register(users);
        } catch (SQLException e) {
            e.printStackTrace();
            throw new BusinessExceeption(e.getMessage());
        }
        return r;
    }
}
